<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]-->
    <script type="text/javascript" src="../../../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../../../lib/respond.min.js?rev=@@hash"></script>
    <!--[endif]-->
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../../../../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="../../../../ht-css/Project.css" />
    <link rel="stylesheet" type="text/css" href="../../../../ht-css/style-q.css" />
    <!--[if IE 6]-->
    <script type="text/javascript" src="../../../../lib/DD_belatedPNG_0.0.8a-min.js?rev=@@hash"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <!--[endif]-->
    <title>活动规则编辑</title>
</head>
<body>
<nav class="breadcrumb">首页 <span class="c-gray en">&gt;积分管理 <span class="c-gray en">&gt;</span> <span onclick="returnVer()" style="cursor: pointer">积分商城</span><span class="c-gray en">&gt;</span> 积分活动管理&gt;</span> 规则编辑<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px ;display:block" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<article class="page-container">
    <form class="ml-20 mr-20" id="appVersionForm"  method="post">
        <div class="bk-gray bg-1 pd-20 text-c">
            <table class="table mt-10 col-2-1" style="margin-left: 35%">

                <tbody>

                <tr>
                    <td>
                        <div style="margin-left: -126px">
                            <label class="form-label f-l w-85 text-r lh-26" style="margin-left: -97px;">规则编辑：</label>
                           <!-- <textarea style=" max-width: 644px;height: 354px;" class="textarea" oninput="checkMaxIut(this)" id="activityRuler"  placeholder="请输入描述" ></textarea>-->
                            <div id="editor" class="formControls col-sm-9">
                            </div>
                        </div>
                    </td>

                </tr>

                </tbody>
            </table>

            <div class="text-c mt-10">
                <input type="button" class="btn btn-secondary radius size-S" value="确认" onclick="save()">
                <input type="button" class="btn radius size-S ml-10" value="取消" onclick="returnVer()">
            </div>
        </div>
    </form>


</article>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../../../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/jquery.validation/1.14.0/messages_zh.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<script src="../../../../ht-js/frame/doT.min.js?rev=@@hash"></script>
<script src="../../../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../../../ht-js/verifyToken.js?rev=@@hash"></script>
<script src="../../../../ht-js/Project.js?rev=@@hash"></script>
<script src="../../../../ht-js/operation-js/operation_activity/activity_login.js?rev=@@hash"></script>
<script src="../../../../ht-js/contract/jquery-form.js?rev=@@hash"></script>
<script type="text/javascript" charset="utf-8" src="../../../../ht-js/operation-js/ueditor/ueditor.config.js?rev=@@hash"></script>
<script type="text/javascript" charset="utf-8" src="../../../../ht-js/operation-js/ueditor/ueditor.all.min.js?rev=@@hash"></script>
<link type="text/css" rel="stylesheet" href="../../../../ht-js/operation-js/time-js/jedate.css">
<script type="text/javascript" src="../../../../ht-js/operation-js/time-js/jquery.jedate.js?rev=@@hash"></script>
<script>
    var idall=""
    var text;
    function returnVer(){
        if($("#activityRuler").val()!=""){
            var curInd = layer.confirm(
                '<span>返回则无法保存当前更新内容</span>'+'<br/>', {title:'提示',btn: ['确定', '取消']}, function(index){
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    layer.close(curInd);

                },function(){
                    layer.close(curInd);

                });
        }else {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        }

    }
    searchIntegralResource()
    function searchIntegralResource() {
        $.ajax({
            url:root.integralManagement.searchIntegralResource,
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            contentType: "application/json",
            data: JSON.stringify({

            }),
            success: function (data) {
                if(data.errorCode==0){
                    idall=data.data.id
                    if(data.data.activityRuler!=""&&data.data.activityRuler!=null){
                        ue.ready(function() {
                            ue.setContent(data.data.activityRuler);
                        });
                    }
                }
            },
            error: function () {
                $.Huimodalalert('失败！',2000);
            }
        })
    }
    var ue = UE.getEditor('editor',{
        enterTag:'' ,
        autoHeightEnabled: true,
        autoFloatEnabled: true,
        initialFrameWidth: 750,
        initialFrameHeight:400
    });
    UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
    UE.Editor.prototype.getActionUrl = function(action) {
        if (action == 'uploadimage' || action == 'uploadvideo' || action == 'uploadfile' ) {
            return root.sroreinter.ueditor; //在这里返回我们实际的上传图片地址
        } else {
            return this._bkGetActionUrl.call(this, action);
        }
    }



    //保存
    function save() {
       /* */
        ue.ready(function() {
            text = ue.getContent();
        });
        console.log(text)
        console.log($(text).html())
        var kk=$(text).html()
        if(text!=""){
        var ss= kk.length;
        if(ss<10){
            $.Huimodalalert('规则不可少于10位',2000);
            return false;
        }
        }else {
            text=""
        }
        $.ajax({
            url:root.integralManagement.addIntegralResource,
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            contentType: "application/json",
            data: JSON.stringify({
                "id":idall,
                "picUrl":"",
                "appUrl":"",
                "activityRuler":text
            }),
            success: function (data) {
                if(data.errorCode==0){
                    layer.msg("成功",{icon: 6,time:1000},function () {
                        var index =  parent.location.reload();
                        parent.layer.close(index);
                    });
                }else {
                    $.Huimodalalert(data.msg,2000)
                }
            },
            error: function () {
                $.Huimodalalert('失败！',2000);
            }
        })
    }



</script>
</body>
</html>